<html>
<head><meta charset="utf-8"><title>test new lang item w/o rebuild whole compiler · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/test.20new.20lang.20item.20w.2Fo.20rebuild.20whole.20compiler.html">test new lang item w/o rebuild whole compiler</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206112801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/test%20new%20lang%20item%20w/o%20rebuild%20whole%20compiler/near/206112801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/test.20new.20lang.20item.20w.2Fo.20rebuild.20whole.20compiler.html#206112801">(Aug 06 2020 at 07:48)</a>:</h4>
<p>Hi, I was wondering if there's anyway to test a new language item without rebuilding the compiler from stage 0 every time. Since it's a new lang item, it's my understanding that it has to be annotated with <code>#[cfg(not(bootstrap))]</code> so that it can be processed in stage 1.  I'm concerned with compile times for testing this feature; and if adding the feature will slow down compile times for as long as it's not in the beta release, so was wondering if there's anyway to test libcore requiring stage 1 without recompiling or for my specific use case of adding a lang item</p>



<a name="206118637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/test%20new%20lang%20item%20w/o%20rebuild%20whole%20compiler/near/206118637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/test.20new.20lang.20item.20w.2Fo.20rebuild.20whole.20compiler.html#206118637">(Aug 06 2020 at 09:07)</a>:</h4>
<p>I might be misunderstanding what you mean, but: </p>
<p>When you add a lang item, it recompiles stage0 std because there have been changes to those files - the result artefact isn't really different because the lang item will have to be annotated with <code>#[cfg_attr(not(bootstrap), lang = ".."]</code> to compile successfully (otherwise the beta compiler that we start with doesn't recognize the lang item) and so there's no semantic change.</p>
<p>Then, when compiling stage1 std, the result is different - we're now compiling with a rustc that knows about that new lang item.</p>
<p>Adding a new lang item results in stage0 std being recompiled - it's potentially possible that this isn't necessary because with only the addition of the lang item then it isn't meaningfully different (but detecting that probably isn't worth it). However, there isn't anything inherent about adding a lang item that will slow down compile times <em>until</em> it is in beta - <em>any</em> change to std will require stage0 std be recompiled, that's why it <em>always</em> happens when you do a local build (it just doesn't get rebuilt unnecessarily unless you change std, most of the time you don't change std when working on rustc) and <em>always</em> gets built in CI. There's nothing about the fact that the lang item isn't in the beta toolchain that would require std be compiled any more or less - it always needs compiled.</p>
<p>Does that make sense?</p>
<p><a href="/user_uploads/4715/CnQwAcJeKBYiZVY5Q3rgNSQE/image.png">bootstrap stages</a><br>
(credit for image: <span class="user-mention" data-user-id="198054">@mark-i-m</span>)</p>
<div class="message_inline_image"><a href="/user_uploads/4715/CnQwAcJeKBYiZVY5Q3rgNSQE/image.png" title="bootstrap stages"><img src="/user_uploads/4715/CnQwAcJeKBYiZVY5Q3rgNSQE/image.png"></a></div>



<a name="206207637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/test%20new%20lang%20item%20w/o%20rebuild%20whole%20compiler/near/206207637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/test.20new.20lang.20item.20w.2Fo.20rebuild.20whole.20compiler.html#206207637">(Aug 06 2020 at 23:00)</a>:</h4>
<p>hmmmm I think it kind of makes sense, will have to let it stir for a bit for it to sink in</p>



<a name="206208988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/test%20new%20lang%20item%20w/o%20rebuild%20whole%20compiler/near/206208988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/test.20new.20lang.20item.20w.2Fo.20rebuild.20whole.20compiler.html#206208988">(Aug 06 2020 at 23:19)</a>:</h4>
<p>you can also use <code>--keep-stage 0</code> which will skip rebuilding std. That has the potential to break things though, it doesn't actually check whether std <em>should</em> be recompiled. <a href="https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=keep-stage#incremental-builds-with---keep-stage">https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=keep-stage#incremental-builds-with---keep-stage</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>